SELE 1
set colo to bg+*/b,w+/n
@ 7,0 CLEA TO 23,79
@ 10, 47  SAY "MODIFY ITEM FOR PURCHASE ORDER"
set colo to bg+/b,w+/n
@ 20,  2  SAY "MODIFY (Y/N) :"
@ 19,  0  TO 21, 21    DOUBLE
OKK=.T.
NDT='N'
ord='y'
num=0
pric=0
qant=0
valu=0
disc=0
netpric=0
suppcod=space(4)
suppnam=space(24)
set colo to bg+/b,w+/n
UL='Y'
BACK='N'
DO CASE
   CASE DAERAH='2'
        NAMA='DRUGS'
        CODEMAC='DRUG_CODE'
        NAMEMAC='DRUG_NAME'
        TYPEMAC='DRUG_TYPE'
        QANTMAC='DRUG_QANT'
        UNITMAC='DRUG_UNIT'
        DRH='4'
   CASE DAERAH='3'
        NAMA='DISPOSIBLE'
        CODEMAC='DISP_CODE'
        NAMEMAC='DISP_NAME'
        TYPEMAC='DISP_TYPE'
        QANTMAC='DISP_QANT'
        UNITMAC='DISP_UNIT'
        DRH='5'
ENDCASE
SELE &DAERAH
GOTO RECNUM
KODE=&CODEMAC
NAME=&NAMEMAC
TIPE=&TYPEMAC
QANT=&QANTMAC
UNIT=&UNITMAC
BUYUNIT=BUY_UNIT
@ 8,0 TO 17,45 DOUBLE
DO WHILE .T.
   @  9,2  SAY NAME
   @  10,2 SAY 'CODE       :'
   @  11,2 SAY 'NAME       :'
   @ 12,2 SAY 'UNIT       :'
   @ 13,2 SAY 'QUANTITY   :'
   @ 14,2 SAY 'UNIT PRICE :'
   @ 15,2 SAY 'DISCOUNT   :       %'
   @ 16,2 SAY 'VALUE      :'

   set colo to GR+/b,w+/n
   @ 10, 15  SAY  KODE
   @ 11, 15  SAY  NAME
   @ 12, 15  SAY  TIPE
   @ 13, 15  SAY  QANT_PURCH PICT '99,999'
   @ 14, 15  SAY  U_PR_PURCH PICT '99,999,999.99'
   @ 15, 15  SAY  DISC_PURCH PICT '99.99'
   @ 16, 15  SAY  VALU_PURCH PICT '99,999,999.99'
   set colo to BG+/b,w+/n
  MOD='Y'
  DO WHILE .T.
     @ 20,19 GET MOD PICT '@!'
     READ
     PRS=LASTKEY()
     IF PRS=27
        BACK='Y'
        RETURN
     ENDIF
     IF MOD='Y' .OR. MOD='N'
        EXIT
     ENDIF
     LOOP
  ENDDO
  IF MOD='N'
     RETURN
  ELSE
    NUM=QANT_PURCH
    PRIC=U_PR_PURCH
    DISC=DISC_PURCH
    VALU=NET_PURCH
    MVALU=NET_PURCH
    DO WHILE .T.
       KODE=&CODEMAC
       @ 10, 15  GET  KODE
       READ
       SELE &DRH
       SEEK KODE
       IF EOF()
          LOOP
       ELSE
          KODE=&CODEMAC
          NAME=&NAMEMAC
          TIPE=&TYPEMAC
          QANT=&QANTMAC
          UNIT=&UNITMAC
          BUYUNIT=BUY_UNIT
          NR=RECNO()
          EXIT
       ENDIF
    ENDDO
    read
    SELE &DAERAH
    @ 11, 15  SAY  NAME
    @ 12, 15  SAY  TIPE
    @ 13, 15  GET  NUM  PICT '99,999'
    DO WHILE .T.
       @ 14, 15  GET  PRIC PICT '99,999,999.99'
       READ
       IF PRIC>0
          EXIT
       ENDIF
    ENDDO
    @ 15, 15  GET  DISC PICT '99.99'
    READ
    VALDISC=DISC/100*PRIC
    NETPRIC=PRIC-VALDISC
    VALU=NUM*NETPRIC
    @ 16, 15  SAY  VALU PICT '99,999,999.99'
    READ
     @ 19, 41 TO 21, 79    DOUBLE
     @ 20, 43  SAY "Confirm -->> Enter   Cancel -->> F4"
     STORE 0 TO MX
     DO WHILE MX=0
        MX=INKEY()
     ENDDO
      DO CASE
         CASE MX=-3
            @ 16,31 CLEA TO 18,79
            @ 19,00 CLEA TO 24,79
            RETURN
         CASE MX=13
            @ 21 ,41 clea to 23,79
            @ 21, 41 TO 23, 65    DOUBLE
            @ 22, 43 SAY "SAVING DATAS"
            SELE &DRH
            GOTO NR
            IF REC_LOCK(0)
               REPL ST_REORDER WITH .T.
               REPL ST_RE_PROP WITH .F.
               REPL ST_RE_QANT WITH NUM
            ENDIF
            UNLOCK
            SELE &DAERAH
            GOTO RECNUM
            if rec_lock(0)
               CODEMAC=SUBS(NAMA,1,4)+'_CODE'
               NAMEMAC=SUBS(NAMA,1,4)+'_NAME'
               TYPEMAC=SUBS(NAMA,1,4)+'_TYPE'
               QANTMAC=SUBS(NAMA,1,4)+'_QANT'
               UNITMAC=SUBS(NAMA,1,4)+'_UNIT'
               REPL &CODEMAC   WITH KODE
               REPL &NAMEMAC   WITH NAME
               REPL &UNITMAC   WITH UNIT
               REPL &TYPEMAC   WITH TIPE
               REPL &QANTMAC   WITH QANT
               REPL BUY_UNIT   WITH BUYUNIT
               REPL U_PR_PURCH WITH PRIC
               REPL QANT_PURCH WITH NUM
               REPL VALU_PURCH WITH NUM*PRIC
               REPL DISC_PURCH WITH DISC
               REPL NET_PURCH WITH VALU
            endif
            unlock

            VAR1=STR(INT(PILIH),2)
            VAR2=SUBST(&NAMEMAC,1,15)
            VAR3=SUBS(&TYPEMAC,1,9)
            VAR4=SUBS(BUYUNIT,1,7)
            VAR5=TRANS(QANT_PURCH,'9,999')
            VAR6=TRANS(U_PR_PURCH,'99,999,999.99')
            IF DISC_PURCH<>0
               VAR7=TRANS(DISC_PURCH,"99.99")+"%"
            ELSE
               VAR7=SPAC(6)
            ENDIF
            VAR8=TRANS(NET_PURCH,"99,999,999.99")
            FILD[PILIH]=VAR1+'  '+VAR2+'    '+VAR3+' '+VAR4+' '+VAR5+' '+VAR6+' '+VAR7+' '+VAR8
*             FILD[ITM]  =VAR1+'  '+VAR2+'    '+VAR3+' '+VAR4+' '+VAR5+' '+VAR6+' '+VAR7+' '+VAR8
            TTL=TTL-MVALU+VALU
            RETURN
      ENDCASE
   ENDIF
ENDDO
RETURN
